package com.bjpowernode.seckillweb.controller;

import com.bjpowernode.constant.Constants;
import com.bjpowernode.vo.HttpResult;

import java.util.Date;

public class SeckillTimeValidator {
    public static HttpResult validateSeckillTime(Date startTime, Date endTime) {
        long currentTime = System.currentTimeMillis();
        long start = startTime.getTime();
        long end = endTime.getTime();
        if (currentTime < start)
            return HttpResult.builder().code(Constants.ERROR).msg("秒杀未开始").build();
        if (currentTime > end)
            return HttpResult.builder().code(Constants.ERROR).msg("秒杀已结束").build();
        return null;
    }
}